package com.xr.baseData;

import com.bstek.dorado.data.*;
import com.bstek.dorado.data.db.SqlDataset;
import com.bstek.dorado.common.*;
import com.xr.common.DBTools;
import com.xr.common.Tools;

/**
 * User_datasetRoleUserListener
 */
public class User_datasetRoleUserListener extends AbstractDatasetListener {
  public boolean beforeLoadData(Dataset dataset) throws Exception {
	  SqlDataset ds = (SqlDataset) dataset;
	  
	  String searchScope = Tools.toStr(dataset.parameters().getString("search_scope"));
	  String roleType = Tools.toStr(dataset.parameters().getString("role_type"));
	  String nodeId = Tools.toStr(dataset.parameters().getString("node_id"));

	  String sql=DBTools.getCertainRoleSql(nodeId,Integer.parseInt(roleType),Integer.parseInt(searchScope));
	  String empName=Tools.toStr(ds.parameters().getString("employee_name"));
	  if (!"".equals(empName)){
		  sql+=" and emp.employee_name like '%"+empName+"%' ";
	  }
	  ds.setSql(sql);
      return true; 
  }

}
